﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Net;

namespace PFAGame.NetworkingGame
{
    class ProjNet
    {
        #region Properties
        public int Id
        {
            get;
            private set;
        }

        public Vector2 Position
        {
            get;
            private set;
        }
        public Vector2 Orientation
        {
            get;
            private set;
        }

        public float Speed
        {
            get;
            private set;
        }

        public AProjectile.e_object ProjType
        {
            get;
            private set;
        }
        #endregion

        public ProjNet(PacketReader packetReader)
        {
            if (packetReader == null)
                throw new ArgumentNullException("packetReader");

            this.Id = packetReader.ReadInt32();
            this.ProjType = (AProjectile.e_object)  packetReader.ReadInt32();
            this.Position = packetReader.ReadVector2();
            this.Orientation = packetReader.ReadVector2();
            this.Speed = packetReader.ReadSingle();
            //if (this.ProjType == AObject.e_object.PROJECTILEQUEEN)
            //    this.Velocity = packetReader.ReadVector2();
        }

        internal static void Serialize(AProjectile proj, PacketWriter packetWriter)
        {
            if (packetWriter == null)
                throw new ArgumentNullException("packetWriter");

            packetWriter.Write(proj.Id);
            packetWriter.Write((int) proj.obj);
            packetWriter.Write(proj.Position);
            packetWriter.Write(proj.Orientation);
            packetWriter.Write(proj.Speed);
            //if (this.ProjType == AObject.e_object.PROJECTILEQUEEN)
            //    packetWriter.Write(proj.Velocity);
        }
    }
}
